package com.educatioin.manage.web.system.controller;

import com.educatioin.manage.common.beans.Response;
import com.educatioin.manage.web.system.response.UserDetailRsp;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;


/**
 * 用户管理模块
 */
@RestController
@RequestMapping(value = {"/api/user"}, method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json;charset=UTF-8", consumes = "application/json;charset=UTF-8")
public class UserController {

    // 登录校验
    @RequestMapping("/detail")
    @ResponseBody
    public UserDetailRsp authLogin(HttpServletRequest req) {
        UserDetailRsp userDetailRsp = new UserDetailRsp();

        //从session中取当前登录用户名和角色名
        HttpSession session = req.getSession();

        userDetailRsp.setReturnCode(Response.RETURN_SUCCESS_CODE);
        userDetailRsp.setUserName((String) session.getAttribute("userName"));
        userDetailRsp.setRoleName((String) session.getAttribute("roleName"));

        return userDetailRsp;
    }

}
